package com.polaris.live.common.util


/**
 * 防止多次点击
 * @author Created by 天晴 on 2023/12/18/014 22:33
 */
object DebounceHelper {
    private var defaultTime = 500
    private var lastClickTime = 0L

    fun singleClick(time: Int = defaultTime, clickAction: () -> Unit) {
        val nowTime = System.currentTimeMillis()
        if (nowTime - lastClickTime > time) {
            clickAction.invoke()
            lastClickTime = nowTime
        }
    }
}